package com.power.flowable.api;

import com.plf.common.domain.ResponseDTO;
import com.plf.common.exception.BusinessException;
import com.power.flowable.model.ProcessNextExecutor;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

/**
 * 外部业务调用的流程接口
 */
@FeignClient(value = "sfflow-svr", contextId = "sfflow-svr", path = "/sfflow-svr")
@RestController
public interface IProcessOutsideFeign {

    /**
     * 外部节点处理业务
     * @param applyid
     * @param userid
     * @param data
     * @return
     */
    @PostMapping("flow/aplTaskExec")
    ResponseDTO aplTaskExec(@RequestParam String applyid, @RequestParam String userid, @RequestBody ProcessNextExecutor data);

    /**
     * 申请编号处理业务
     * @param applycode
     * @param userid
     * @param data
     * @return
     */
    @PostMapping("flow/aplTaskExecByApplycode")
    ResponseDTO aplTaskExecByApplycode(@RequestParam String applycode, @RequestParam String userid, @RequestBody ProcessNextExecutor data) throws BusinessException;

    /**
     * 外部节点退回业务
     * @param handletext: 操作按钮的处理文字
     * @param applyid 申请表id
     * @param userid
     * @param remark 审批意见
     * @return
     */
    @PostMapping("flow/aplTaskBack")
    ResponseDTO aplTaskBack(@RequestParam String applyid,  @RequestParam(required = false) String handletext, @RequestParam String userid, @RequestParam(required = false) String remark);

    /**
     * 外部节点退回业务
     * @param handletext: 操作按钮的处理文字
     * @param applycode 申请编号
     * @param userid
     * @param remark 审批意见
     * @return
     */
    @PostMapping("flow/aplTaskBackByApplycode")
    ResponseDTO aplTaskBackByApplycode(@RequestParam String applycode, @RequestParam(required = false) String handletext, @RequestParam  String userid,  @RequestParam(required = false) String remark);


    /**
     * 外部节点挂起业务
     * @param applyid
     * @return
     */
    @PostMapping(value = "flow/aplSuspendProcess")
    ResponseDTO aplSuspendProcess(@RequestParam String applyid, @RequestParam(required = false) String userid, @RequestParam(required = false) String remark);

    /**
     * 认证中心激活业务
     * @param applyid
     * @param handletext 操作
     * @param userid
     * @param remark 意见
     * @return
     */
    @PostMapping("flow/rzActivateProcess")
    ResponseDTO rzActivateProcess(@RequestParam String applyid, @RequestParam(required = false) String handletext, @RequestParam String userid, @RequestParam String remark);

    /**
     * 查询流程实例任务分类标识列表
     * @param applyid
     * @return
     */
    @PostMapping(value = "flow/aplFindCategory")
    ResponseDTO aplFindCategory(@RequestParam String applyid);

    /**
     * 查询流程任务的执行人, 没有进行抢占
     * @param taskid
     * @param userid
     * @return
     */
    @PostMapping(value = "flow/aplExecutor")
    ResponseDTO aplExecutor(@RequestParam String taskid, @RequestParam String userid);

    /**
     * 外部节点终止业务
     * @param handletext: 操作按钮的处理文字
     * @param applycode 申请编号
     * @param userid
     * @param remark 审批意见
     * @return
     */
    @PostMapping("flow/aplTaskTerminationByApplycode")
    ResponseDTO aplTaskTerminationByApplycode(@RequestParam String applycode, @RequestParam(required = false) String handletext, @RequestParam String userid,  @RequestParam(required = false) String remark);

    /**
     * 根据申请编号查询流程任务id
     * @param applycode
     * @return
     */
    @PostMapping("flow/findTaskIdByApplyno")
    ResponseDTO findTaskIdByApplyno(@RequestParam String applycode);

}
